import React, { Component } from "react";
import memoryUtils from "../../utils/memoryUtils.js"
import { Redirect, Route, Switch } from "react-router-dom"
import HeaderLaout from "../../components/header/index.jsx"
import LeftNav from "../../components/left-nav/index.jsx";
import { Layout } from 'antd';
import Home from "../home/index.jsx";
import Product from "../product/index.jsx";
import Charts from "../charts/index.jsx";
const { Footer, Sider, Content } = Layout;
export default class Admin extends Component {

    render() {
        const { username } = memoryUtils.userInfo

        if (!username) {
            return <Redirect to="/login" />
        }
        return (
            <Layout style={{ height: '100%' }}>
                <Sider>
                    <LeftNav></LeftNav>
                </Sider>
                <Layout>

                    <HeaderLaout></HeaderLaout>

                    <Content>
                        <Switch>
                            <Route to="/home" component={Home}></Route>
                            <Route to="/product" component={Product}></Route>
                            <Route to="/charts" component={Charts}></Route>
                            <Redirect  to="/home"></Redirect>
                        </Switch>
                    </Content>
                    <Footer>Footer</Footer>
                </Layout>
            </Layout>
        )
    }
}